import http from '@/api';
import { ADMIN_MODULE } from '@/api/helper/prefix';
import type { IPage } from '@/api/types';
import type { VehicleScheduleQuery, VehicleScheduleRow, VehicleScheduleForm } from '@/api/types/vehicleschedule/vehicleSchedule';
import type { UploadRawFile } from 'element-plus/es/components/upload/src/upload';
import type { AxiosRequestConfig } from 'axios';

/**
 * 查询列表
 * @param params
 * @returns {*}
 */
export const getVehicleScheduleListApi = (params: VehicleScheduleQuery) => {
  return http.get<IPage<VehicleScheduleRow>>(ADMIN_MODULE + `/vehicle-schedule`, params);
};

/**
 * 添加
 * @param params
 * @returns {*}
 */
export const createVehicleScheduleApi = (params: VehicleScheduleForm) => {
  return http.post(ADMIN_MODULE + `/vehicle-schedule`, params);
};

/**
 * 修改
 * @param params
 * @returns {*}
 */
export const updateVehicleScheduleApi = (params: VehicleScheduleForm) => {
  return http.put(ADMIN_MODULE + `/vehicle-schedule`, params);
};

/**
 * 删除
 * @param params
 * @returns {*}
 */
export const removeVehicleScheduleApi = (params: { ids: (string | number)[] }) => {
  return http.delete(ADMIN_MODULE + `/vehicle-schedule`, params);
};

/**
 * 获取详情
 * @param params
 * @returns {*}
 */
export const getVehicleScheduleDetailApi = (params: { id: number }) => {
  const { id } = params;
  return http.get<VehicleScheduleRow>(ADMIN_MODULE + `/vehicle-schedule/${id}`);
};

/**
 * 导入excel
 * @param params
 */
export const importVehicleScheduleExcelApi = (params: UploadRawFile, config?: AxiosRequestConfig<any> | undefined) => {
  return http.upload(ADMIN_MODULE + `/vehicle-schedule/import`, params, config);
};

/**
 * 导出excel
 * @param params
 * @returns {*}
 */
export const exportVehicleScheduleExcelApi = (params: VehicleScheduleQuery) => {
  return http.download(ADMIN_MODULE + `/vehicle-schedule/export`, params);
};
/**
 * list
 */
export const getVehicleScheduleListNopApi = (params: VehicleScheduleQuery) => {
  return http.get<VehicleScheduleRow>(ADMIN_MODULE + `/vehicle-schedule/nop`, params);
};
